package com.itheima.d1_map_impl;

import java.util.Comparator;
import java.util.TreeMap;

/**
 * 目标：掌握TreeMap集合的使用。
 */
public class Test3TreeMap {
    public static void main(String[] args) {
        TreeMap<Integer,String>map = new TreeMap<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2.compareTo(o1);
            }
        });

        map.put(1,"");
        map.put(3,"");
        map.put(5,"");
        map.put(2,"");
        map.put(1,"");
        map.put(4,"");
        map.put(3,"");

        System.out.println(map);//{1=, 2=, 3=, 4=, 5=},默认升序排序
    }
}
